import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import p004 from './p004';
export default async function a004(fd: IFeidaoAiBrowserComponent, e: Event) {
	// todo
	const n = e.currentTarget as HTMLDivElement;
	const d = n.getAttribute('data-no');
	const res = await nodejs<Array<{ staff_no: string }>>('notification-notice/zj-000006/s002', {
		filter: {
			staff_no: d
		}
	});
	const data = res.map((v) => {
		return { ...v, v: JSON.stringify(v) };
	});
	const arr1 = Array();
	const div = fd.data.node.querySelectorAll<HTMLDivElement>('[data-id="getUser"]');
	for (let i = 0; i < div.length; i++) {
		arr1.push(div[i].getAttribute("data-no"));
	}
	let a = 0;
	for (let j = 0; j < div.length; j++) {
		if (data[0].staff_no === arr1[j]) {
			a++;
		}
	}
	if (a === 1) {
		alert('已添加！');
	} else {
		render(fd, data, p004, 'p004', 'lastin');

	}
}
